
local skynet = require "skynet"
local json = require "json"

local logger = require "logger"
local utils = require "utils"
local MSG_RESULT = require "msgresult"

local cdkserver = "cdkserver"
local noticeserver = "noticeserver"
local emailserver = "emailserver"
local payserver = "payserver"


--公告

function rep.getNotice(req)
-- method,header,body,query
	local query = req.query

	local ret = skynet.call(noticeserver, "lua", "getNotice")
	-- utils.dumpprint(ret)
	return 200,json.encode(ret)
end

function rep.addNotice(req)
-- method,header,body,query
	local query = req.query

	-- utils.dumpprint(query)
	
	local ret = skynet.call(noticeserver, "lua", "addNotice", query.nid,query.title,query.notice)
	-- utils.dumpprint(ret)
	return 200,json.encode({result = MSG_RESULT.SUCCESS})
end

function rep.removeNotice(req)
-- method,header,body,query
	local query = req.query

	local ret = skynet.call(noticeserver, "lua", "removeNotice", query.nid)
	-- utils.dumpprint(ret)
	return 200,json.encode({result = MSG_RESULT.SUCCESS})
end

--tocmd

function rep.cmd(req)
-- method,header,body,query
	local query = req.query
	local server = query.server
	local func = query.func

	local ret = skynet.call(server, "lua", func, query.v1,query.v2,query.v3)
	-- utils.dumpprint(ret)
	return 200,json.encode({result = MSG_RESULT.SUCCESS})
end
